<template>
  <div class="app-container">
    <el-card>
      <div class="catalogue-box">
        <div class="app-container catalogue-left">
          <el-tree
            :data="dataList"
            node-key="id"
            :props="{
              children: 'childList',
              label: 'name',
            }"
            :highlight-current="true"
            :default-expand-all="true"
            :expand-on-click-node="false"
            @node-click="nodeClick"
          ></el-tree>
        </div>
        <div class="catalogue-right">
          <List ref="listRef"></List>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
  import List from './components/list.vue'
  import { depCategoryList } from '@/api/dep/index.js'
  export default {
    components: {
      List,
    },
    data () {
      return {
        dataList: [],
      }
    },
    created () {
      this.getList()
    },

    methods: {
      nodeClick (data) {
        this.$refs.listRef.getList(data.id)
      },
      async getList () {
        let data = await depCategoryList()
        this.dataList = data.result
      },
    },
  }
</script>

<style scoped lang="scss">
  .catalogue-box {
    display: flex;

    .catalogue-left {
      width: 250px;
    }

    .catalogue-right {
      flex: 1;
    }
  }

  .custom-tree-node {
    flex: 1;
    font-size: 14px;
    padding-right: 8px;
    position: relative;

    .custom-tree-node-set {
      position: absolute;
      right: 0;
      top: 0;
      // transform: translateY(-50%);
    }
  }
</style>
